<?php
session_start(); 
include 'connect.php';
mysql_query ('SET NAMES \'UTF8\'');
?>

<!DOCTYPE html> 
<html> 
	<head> 
	<title>[Rec]ON - Accueil</title> 
	<meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1, user-scalable=no" /> 
	<link rel="stylesheet" href="http://code.jquery.com/mobile/1.0.1/jquery.mobile-1.0.1.min.css" />
	<link rel="stylesheet" href="mobile/themes/recontv-theme.css" />
	<link rel="stylesheet" href="mobile/stylesmobile.css" />
	<script src="http://code.jquery.com/jquery-1.6.4.min.js"></script>
	<script src="http://code.jquery.com/mobile/1.0.1/jquery.mobile-1.0.1.min.js"></script>
	<meta http-equiv="Content-Type" content="text/html;charset=utf-8" />
	<script type="text/javascript">
	// a enlever laisser en prod -- if (screen.width >640) location="http://recontv.fr"; 
</script>
</head> 
<body> 


<div data-role="dialog" id="erreur">

	<div data-role="header">
		<h1>Erreur 404</h1>
	</div><!-- /header -->

	<div data-role="content">	
        <p>La page n'a pas été créée/retrouvée</p>
	</div><!-- /content -->

</div><!-- /page -->

<div data-role="page" id="index">

	<div data-role="header">
		<a data-role="button" data-icon="search" data-iconpos="notext" data-inline="true" href="#erreur" data-transition="pop"></a>
		<h1>[REC]ON - Accueil</h1>
	</div><!-- /header -->
	
	<div data-role="content">
	
		<div data-role="controlgroup" data-type="horizontal" style="margin:auto; width:239px;">
			<a data-role="button" data-icon="video" data-inline="true" data-ajax="false" data-iconpos="left" href="mobile/allvideos.php">Vidéos</a>
			<a data-role="button" data-icon="article" data-inline="true" data-ajax="false" data-iconpos="left" href="mobile/allarticles.php">Articles</a>
		</div>
	
        	<ul data-role="listview" data-inset="true" data-theme="d" data-divider-theme="d">
                <li data-role="list-divider">A la une</li>
                <?php
            		//Requête SQL
            		$result = mysql_query('
					SELECT reportage.image, reportage.titre, reportage.date, auteur.pseudo, SUBSTRING( reportage.contenu, 1, 250 ) AS texte, type.nom_type, reportage.id_reportage, SUBSTRING( reportage.article_clean, 1, 250 ), id_vimeo
					FROM reportage, auteur, type 
					WHERE reportage.id_auteur = auteur.id_auteur 
					AND type.id_type = reportage.id_type 
					AND reportage.id_type != 5 
					AND reportage.id_type != 4 
					ORDER BY DATE DESC  
					LIMIT 0 , 1
					');
					
        
            		// Boucle pour afficher les resultats
            		while($row = mysql_fetch_row($result)){
        		?>
                <li>
                 <!-- A La Une -->
                    <a data-ajax="false" href="mobile/<?php echo $row[5];?>.php?id=<?php echo $row[6]; if ($row[8] != NULL) {echo '&id_vimeo='.$row[8].'';}?>&page=0&ajout=0">
                    	<img class="uneimg" src="../../../../images/<?php echo $row[0]?>" /> <!-- Images -->
                    	<h3><u><?php echo $row[1]; ?></u></h3><!-- 1->Titre -->
                    	<p>
                        	<i class="uneauteur"><?php echo 'Par '.$row[3].', le '.$row[2].''; ?></i> <!-- 3->Auteur  -->  <!-- 2->Date --> 
                    	</p>
                    	<p class="unecontenu">
                        	<?php if ($row[7] == NULL) { 
								echo $row[4];  //contenu des vidéos
							}
							else {
								echo $row[7]; //Contenu article
							}
							?>
                    	</p>
                	<?php
                		}
                	?>
                	</a>
                </li>
                
                <li data-role="list-divider">Dernière news</li>
                <?php
					// Requête SQL affichant les 4 dernières news
					$result = mysql_query('
					SELECT reportage.image, reportage.titre, reportage.date, auteur.pseudo, SUBSTRING( reportage.contenu, 1, 130 ) AS texte, reportage.id_reportage, type.nom_type, SUBSTRING( reportage.article_clean, 1, 250), id_vimeo
					FROM reportage, auteur, type
					WHERE reportage.id_auteur = auteur.id_auteur
					AND type.id_type = reportage.id_type
					AND reportage.id_type != 5
					ORDER BY DATE DESC LIMIT 1 , 4
					');

					// Boucle pour afficher les resultats
					while($row = mysql_fetch_row($result)){
				?>
				<li>
                 <!-- A La Une -->
                    <a data-ajax="false" href="mobile/<?php echo $row[6];?>.php?id=<?php echo $row[5]; if ($row[8] != NULL) {echo '&id_vimeo='.$row[8].'';}?>&page=0&ajout=0">
                    	<img class="uneimg" src="../../../../images/<?php echo $row[0]?>" /> <!-- Images -->
                    	<h3><u><?php echo $row[1]; ?></u></h3><!-- 1->Titre -->
                    	<p>
                        	<i class="uneauteur"><?php echo 'Par '.$row[3].', le '.$row[2].''; ?></i> <!-- 3->Auteur  -->  <!-- 2->Date --> 
                    	</p>
                    	<p class="unecontenu">
                        	<?php if ($row[7] == NULL) { 
								echo $row[4];  //contenu des vidéos
							}
							else {
								echo $row[7]; //Contenu article
							}
							?>
                    	</p>
                	</a>
                </li>
				<?php
					}
				?>
			</ul>
	</div><!-- /content -->

</div><!-- /index -->

</body>
</html>